{extend name="base/main" /}
{block name="body"}
 
<form class="layui-form" action="{:url('Recommend/add')}" method="post">
  <div class="layui-form-item">
    <label class="layui-form-label">列表名称</label>
    <div class="layui-input-inline">
      <input type="text" name="name" required  lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input">
    </div>
  </div>

 <div class="layui-form-item">
    <label class="layui-form-label">排序</label>
    <div class="layui-input-inline">
      <input type="text" name="age" required  lay-verify="required" placeholder="请输入链接" autocomplete="off" class="layui-input">
    </div>
  </div>
 
<div class="layui-form-item">
    <div class="layui-inline">
      <label class="layui-form-label">排版选择</label>
      <div class="layui-input-inline">
        <select name="paiban">
          <option value="1">大图</option>
          <option value="2">宫图</option>
          <option value="3">小图</option>
          <option value="4">左右切换</option>
        </select>
      </div>
    </div>
    <div class="layui-inline">
      <label class="layui-form-label">类型选择</label>
      <div class="layui-input-inline">
        <select name="type" lay-verify="required" lay-search="">
          <option value="专题">专题</option>
        </select>
      </div>
    </div>
  </div>

<div class="layui-form-item">
    <label class="layui-form-label">一级分类</label>
    <div class="layui-input-block">
      <select name="" lay-filter="aihao">
        <option value="全部" checked="">全部</option>
        <option value="八维">八维</option>
        <option value="全栈开发">全栈开发</option>
        <option value="网站开发">网站开发</option>
        <option value="云计算">云计算</option>
        <option value="大数据">大数据</option>
      </select>
    </div>
  </div>

<div class="layui-form-item">
    <label class="layui-form-label">列表展示</label>
    <div class="layui-input-inline">
      <input type="text" name="zhanshi" required  lay-verify="required" placeholder="请输入链接" autocomplete="off" class="layui-input">
    </div>
  </div>

  <div class="layui-form-item">
    <div class="layui-input-block">
      <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
      <button type="reset" class="layui-btn layui-btn-primary">重置</button>
    </div>
  </div>
</form>
 
<script>
//Demo
layui.use(['upload', 'element', 'layer','form'], function(){
        var $ = layui.jquery
            ,upload = layui.upload
            ,element = layui.element
            ,layer = layui.layer;
        //常规使用 - 普通图片上传
        var uploadInst = upload.render({
            elem: '#test1'
            ,url: "{:url('Recommend/upload')}" //改成自己的上传接口
            ,before: function(obj){
                //预读本地文件示例
                obj.preview(function(index, file, result){
                    $('#demo1').attr('src', result); //图片链接（base64）
                });
            }
            ,done: function(res){
                //如果上传失败
                if(res.code > 0){
                    return layer.msg('上传失败');
                }
                if(res.code == 0){
                    $('#img').val(res.data);
                    return layer.msg('上传成功');
                }
                //上传成功的一些操作
                //……
                $('#demoText').html(''); //置空上传失败的状态
            }
            ,error: function(){
                //演示失败状态，并实现重传
                var demoText = $('#demoText');
                demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
                demoText.find('.demo-reload').on('click', function(){
                    uploadInst.upload();
                });
            }
        });
 });
</script>
{/block}